package puke;

import java.util.*;

public class Doudizhu {
    public static ArrayList<Card> list = new ArrayList();
    public static List a = new ArrayList();
    public static List b = new ArrayList();
    public static List c = new ArrayList();
    public static List d = new ArrayList();

    //初始化54张扑克牌
    public void init() {
        String type;
        for (int i = 1; i <= 4; i++) {
            if (i == 1) {
                type = "♠";
                for (int j = 1; j <= 13; j++) {
                    String number = j + "";
                    list.add(new Card(number, type, j));
                }
            }
            if (i == 2) {
                type = "♥";
                for (int j = 1; j <= 13; j++) {
                    String number = j + "";
                    list.add(new Card(number, type, j));
                }
            }
            if (i == 3) {
                type = "♣";
                for (int j = 1; j <= 13; j++) {
                    String number = j + "";
                    list.add(new Card(number, type, j));
                }
            }
            if (i == 4) {
                type = "♦";
                for (int j = 1; j <= 13; j++) {
                    String number = j + "";
                    list.add(new Card(number, type, j));
                }
            }
        }
        list.add(new Card("WANG", "(ˆ◡ˆԅ)", 15));
        list.add(new Card("wang", "(ˆ◡ˆԅ)", 14));

    }

    //洗牌
    public void xipai() {
        Collections.shuffle(list);
    }

    //发牌
    public void send() {
        a = list.subList(0, 17);
        b = list.subList(17, 34);
        c = list.subList(34, 51);
        d = list.subList(51, 54);

    }

    // 理牌
    public void lipai() {
        a.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o1.getWeight()-o2.getWeight();
            }
        });
        b.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o1.getWeight()-o2.getWeight();
            }
        });

        c.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o1.getWeight()-o2.getWeight();
            }
        });



    }

    public static void main(String[] args) {
        Doudizhu doudizhu = new Doudizhu();
        doudizhu.init();
        doudizhu.xipai();
        doudizhu.send();
        doudizhu.lipai();
        System.out.print("玩家A：");
        for (Object obj : a) {
            System.out.print(obj);
        }
        System.out.println();
        System.out.print("玩家B：");
        for (Object obj : b) {
            System.out.print(obj);
        }
        System.out.println();
        System.out.print("玩家C：");
        for (Object obj : c) {
            System.out.print(obj);
        }
        System.out.println();
        System.out.print("牌库剩余：");
        for (Object obj : d) {
            System.out.print(obj);
        }
    }
}
